]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
windowManager: Move animation into WindowDimmer
authorFlorian Müllner <fmuellner@gnome.org>
Sun, 22 Jul 2018 01:31:54 +0000 (03:31 +0200)
committerFlorian Müllner <fmuellner@gnome.org>
Tue, 6 Aug 2019 21:54:29 +0000 (23:54 +0200)
Currently WindowDimmer exposes a JS property that is used to control the
underlying effect. This works fine with Tweener, but not with Clutter
animations which we want to use ultimately.

As a first step towards that, expose a setDimmed() method instead of
the property and handle the animation internally, so it can be adapted
more easily.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/666

js/ui/windowManager.js

index d932c22fbdbda4ff73f0ea7ba40c2f60830323cb..f7e4dc211fa29bdff92a3997cbbad5a33e0f809a 100644 (file)
@@ -135,14 +135,25 @@ var WindowDimmer = class {
         this._syncEnabled();
     }
 
-    set dimFactor(factor) {
-        this._dimFactor = factor;
-        this._brightnessEffect.set_brightness(factor * DIM_BRIGHTNESS);
-        this._syncEnabled();
-    }
-
-    get dimFactor() {
-        return this._dimFactor;
+    setDimmed(dimmed, animate) {
+        let factor = dimmed ? 1.0 : 0.0;
+
+        if (animate) {
+            Tweener.addTween(this, {
+                _dimFactor: factor,
+                time: (dimmed ? DIM_TIME : UNDIM_TIME) / 1000,
+                transition: 'linear',
+                onUpdate: () => {
+                    let brightness = this._dimFactor * DIM_BRIGHTNESS;
+                    this._brightnessEffect.set_brightness(brightness);
+                    this._syncEnabled();
+                }
+            });
+        } else {
+            this._dimFactor = factor;
+            this._brightnessEffect.set_brightness(factor * DIM_BRIGHTNESS);
+            this._syncEnabled();
+        }
     }
 };
 
@@ -1582,14 +1593,7 @@ var WindowManager = class {
         let dimmer = getWindowDimmer(actor);
         if (!dimmer)
             return;
-        if (this._shouldAnimate())
-            Tweener.addTween(dimmer,
-                             { dimFactor: 1.0,
-                               time: DIM_TIME / 1000,
-                               transition: 'linear'
-                             });
-        else
-            dimmer.dimFactor = 1.0;
+        dimmer.setDimmed(true, this._shouldAnimate());
     }
 
     _undimWindow(window) {
@@ -1599,13 +1603,7 @@ var WindowManager = class {
         let dimmer = getWindowDimmer(actor);
         if (!dimmer)
             return;
-        if (this._shouldAnimate())
-            Tweener.addTween(dimmer,
-                             { dimFactor: 0.0,
-                               time: UNDIM_TIME / 1000,
-                               transition: 'linear' });
-        else
-            dimmer.dimFactor = 0.0;
+        dimmer.setDimmed(false, this._shouldAnimate());
     }
 
     _mapWindow(shellwm, actor) {